<?php
namespace Mall\Controller;

use Common\Controller\ApiController;
use Common\Model\ModelException;
use Util\Tree;

class GoodsCateController extends ApiController
{
    public function index()
    {
        $cates = D('GoodsCate')->scope('valid')->order('orderby asc')->select();
        $tree = new Tree('cate_id', 'parent_id');
        $tree->load($cates);
        $cates = transform('GoodsCate', 'listview', $tree->deepTree());
        $this->response($cates);
    }
}
